package com.example.patient.controller;

import com.example.common.entity.CheckupProduct;
import com.example.common.entity.CheckupReserve;
import com.example.common.support.Result;
import com.example.patient.dto.req.AppointmentCheckUpDto;
import com.example.patient.dto.resp.CheckupProductList;
import com.example.patient.dto.resp.CheckupReserveList;
import com.example.patient.dto.resp.GetCheckTypeList;
import com.example.patient.service.CheckupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @ClassName CheckupController
 * @Author wengjt
 * @Date 2021/5/8 16:20
 * @Description
 **/
@RestController
@RequestMapping("/checkupReserve")
@Api(tags = "预约体检服务")
public class CheckupController {
    @Resource
    private CheckupService checkupService;

    @ApiOperation(value = "体检分类列表")
    @GetMapping("/checkType/list")
    public Result<GetCheckTypeList> getCheckTypeList(Integer ctId,
                                                     Integer showAble,
                                                     Integer pageNum,
                                                     Integer pageSize) {
        return Result.success(checkupService.getCheckTypeList(ctId, showAble, pageNum, pageSize));
    }

    @ApiOperation(value = "体检套餐列表")
    @GetMapping("/checkProduct/list")
    public Result<CheckupProductList> getCheckupProductList(String cpName,
                                                            Long ctId,
                                                            Integer showAble,
                                                            Integer recommend,
                                                            Integer pageNum,
                                                            Integer pageSize) {
        return Result.success(checkupService.getCheckupProductList(cpName, ctId, showAble, recommend, pageNum, pageSize));
    }

    @ApiOperation(value = "体检套餐详情")
    @GetMapping("/checkProduct")
    public Result<CheckupProduct> getInfo(Long cpId) {
        return Result.success(checkupService.getInfo(cpId));
    }

    @ApiOperation(value = "预约体检套餐")
    @PostMapping("/checkProduct/appointment")
    public Result<Object> appointmentCheckup(@RequestBody AppointmentCheckUpDto appointmentCheckUpDto, @RequestHeader(value = "uid") Long uid) {
        return Result.success(checkupService.appointmentCheckup(uid, appointmentCheckUpDto.getCpId(), appointmentCheckUpDto.getPid(), appointmentCheckUpDto.getReserve(), appointmentCheckUpDto.getLinkman(), appointmentCheckUpDto.getLinkTel()));
    }

    @GetMapping("/list")
    @ApiOperation(value = "获取病患体检订单列表")
    public Result<CheckupReserveList> getCheckupReserveList(Integer rStatus, Integer pageNum, Integer pageSize, @RequestHeader(value = "uid") Long uid) {
        return Result.success(checkupService.getCheckupReserveList(uid, rStatus, pageNum, pageSize));
    }
}
